<template>
  <div class="tab-box">
    <div v-if="navigator === 'mobile'" class="h5">
      <div class="navbar-title">
        {{ componentData.titleZh }}
      </div>
      <div class="navbar-subtitle">
        <span>发布时间: --</span>
        <span>来源: {{ componentData.sourceZh }}</span>
      </div>
      <div class="navbar-box">
        <div v-for="(item, index) in componentData.list" :key="index" class="navbar-in">
          <p
            v-if="item.type === 'text'"
            :class="{
              indent: item.indent === '1',
              'align-ct': item.align === '2',
              'align-fr': item.align === '3',
            }"
            class="navbar-content"
          >
            {{ item.content }}
          </p>
          <template v-if="item.type === 'image'">
            <div v-for="(c, cindex) in item.content" :key="cindex" class="navbar-image">
              <img :src="c.response" alt="" />
              <span v-if="item.url">点击图片(查看原文)</span>
            </div>
          </template>
        </div>
      </div>
    </div>
    <div v-else class="pc">
      <div class="navbar-box">
        <div class="navbar-title">
          {{ componentData.titleZh }}
        </div>
        <div class="navbar-subtitle">
          <span>发布时间: --</span>
          <span>来源: {{ componentData.sourceZh }}</span>
        </div>
        <div v-for="(item, index) in componentData.list" :key="index" class="navbar-in">
          <p
            v-if="item.type === 'text'"
            :class="{
              indent: item.indent === '1',
              'align-ct': item.align === '2',
              'align-fr': item.align === '3',
            }"
            class="navbar-content"
          >
            {{ item.content }}
          </p>
          <template v-if="item.type === 'image'">
            <div v-for="(c, cindex) in item.content" :key="cindex" class="navbar-image">
              <img :src="c.response" alt="" />
              <span v-if="item.url">点击图片(查看原文)</span>
            </div>
          </template>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    componentData: {
      type: Object,
      default: () => ({}),
    },
    // 设备型号
    navigator: {
      type: String,
      default: '',
    },
  },
  data() {
    return {
      currentNavbar: 0,
    }
  },
  computed: {
    currentDetail() {
      return this.componentData.list[this.currentNavbar]?.detail || []
    },
  },
}
</script>

<style lang="less" scoped>
@import '~assets/var';

.tab-box {
  background: #fff;

  .h5 {
    padding: 0;
    color: #fff;
    background: #f6f7f9;
    margin: 0 12px;

    .navbar-title {
      font-size: 18px;
      padding: 16px 20px 10px 20px;
      margin-top: 30px;
      border-bottom: 1px solid #ddd;
      font-weight: bold;
      color: #333;
      text-align: center;
    }

    .navbar-subtitle {
      font-size: 11px;
      margin: 8px 0 10px 0;
      color: #888;
      text-align: center;

      span {
        margin: 0 20px;
      }
    }

    .navbar-box {
      margin-top: 0;
      padding: 12px;
      color: #666;

      .navbar-in {
        font-size: 12px;
        font-weight: 500;
        line-height: 15px;
      }

      .navbar-image {
        img {
          width: 100%;
          margin-bottom: 15px;
        }

        span {
          color: #999;
          display: block;
          text-align: center;
          margin-top: -15px;
          margin-bottom: 15px;
        }
      }

      .navbar-content {
        margin-bottom: 15px;
        color: #333;

        &.indent {
          text-indent: 2em;
        }

        &.align-ct {
          text-align: center;
        }

        &.align-fr {
          text-align: right;
        }
      }
    }
  }

  .pc {
    .width(1200);
    .pd(0, 0, 0, 0);

    background: #f6f7f9;
    color: #fff;
    border: 1px dashed #e0e4ec;
    margin: 0 auto;

    .navbar-box {
      .mg(20, 100, 30, 100);

      display: flex;
      flex-direction: column;
    }

    .navbar-in {
      .mg(0, 0, 0, 0);
      .lineH(24);
      .ft(16);
    }

    .navbar-title {
      .ft(24);
      .mg(16, 0, 16, 0);

      border-bottom: 1px solid #ddd;
      font-weight: bold;
      color: #333;
      text-align: center;
    }

    .navbar-subtitle {
      .ft(16);
      .mg(0, 0, 20, 0);

      color: #888;
      text-align: center;

      span {
        .mg(0, 70, 0, 70);
      }
    }

    .navbar-image {
      img {
        width: 100%;
        .mg(0, 0, 20, 0);
      }

      span {
        color: #999;
        display: block;
        text-align: center;
        .mg(-20, 0, 20, 0);
      }
    }

    .navbar-content {
      .mg(0, 0, 20, 0);

      color: #333;

      &.indent {
        text-indent: 2em;
      }

      &.align-ct {
        text-align: center;
      }

      &.align-fr {
        text-align: right;
      }
    }
  }
}
</style>
